package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.object.pojo.OrderHelmetLostLog;
import com.tbit.uqbike.object.pojo.vo.OrderHelmetLostLogQueryReqVO;
import com.tbit.uqbike.object.view.JsonResult;
import com.tbit.common.entity.view.PageResult;
import com.tbit.uqbike.service.business.OrderHelmetLostLogService;
import com.tbit.uqbike.webmanager.util.excel.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yao
 * @since 2025/2/28 10:05
 */
@RestController
@RequestMapping("/orderHelmetLostLog")
public class OrderHelmetLostLogController {

    @Autowired
    private OrderHelmetLostLogService orderHelmetLostLogService;

    @GetMapping("/getPage")
    public JsonResult getPage(OrderHelmetLostLogQueryReqVO reqVO) {
        return JsonResult.ok(orderHelmetLostLogService.getPage(reqVO));
    }

    @GetMapping("/export")
    public JsonResult export(OrderHelmetLostLogQueryReqVO reqVO) {
        reqVO.setRowCount(-1);
        PageResult<OrderHelmetLostLog> page = orderHelmetLostLogService.getPage(reqVO);
        return JsonResult.ok(new ExcelUtil<>(OrderHelmetLostLog.class).exportExcel(page.getList(), "订单头盔丢失统计").getData());
    }

    @GetMapping("/getList")
    public JsonResult getList() {
        return JsonResult.ok(orderHelmetLostLogService.getList());
    }

    @GetMapping("/getById")
    public JsonResult getById(Integer id) {
        return JsonResult.ok(orderHelmetLostLogService.getById(id));
    }

    @PostMapping("/create")
    public JsonResult create(@RequestBody OrderHelmetLostLog log) {
        orderHelmetLostLogService.create(log);
        return JsonResult.ok();
    }

    @PostMapping("/update")
    public JsonResult update(@RequestBody OrderHelmetLostLog log) {
        orderHelmetLostLogService.update(log);
        return JsonResult.ok();
    }

    @PostMapping("/delete")
    public JsonResult delete(Integer id) {
        orderHelmetLostLogService.delete(id);
        return JsonResult.ok();
    }
}
